﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Markup;
using System.Threading;
using System.Threading.Tasks;
using System.Xaml;
using System.Runtime.CompilerServices;

using alib;
using alib.Debugging;
using alib.Reflection;

using agree.configuration;
using agree.schema;

namespace agree
{
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/// 
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	[UsableDuringInitialization(true)]
	public sealed class Grammar : identity_node_named,
		ρρAgreeConfig,
		ρρItemCulture,
		ρρDefaultDirectories,
		ρρDisplayName,
		ρρAuthor,
		ρρTypeDictionary,
		ρρTypeUtils,
		ρρGlbCache,
		ρρFeatMgr,
		ρρIsometrics,
		ρρTypeLattice,
		ρρTfsUnifier,
		ρρEntryMgr,
		ρρNodeLabeler,
		ρρMrsManager,
		ρρQuickCheck,
		ρρSemI,
		ρρVpm
	{
		static Grammar[] arr;

		public static Grammar FindGrammar(String s_name)
		{
			Grammar g;
			var tmp = arr;
			for (int i = 0; i < tmp.Length; i++)
				if ((g = tmp[i]) != null && g.IsNameMatch(s_name))
					return g;
			return default(Grammar);
		}
		public static Grammar GetGrammar(int ix)
		{
			var tmp = arr;
			return ix < tmp.Length ? tmp[ix] : null;
		}

#if DEBUG
		static Grammar _debug_grm;
		public static Grammar DebugGrammar
		{
			get { return _debug_grm ?? arr[0]; }
			set { _debug_grm = value; }
		}
#endif

		public Grammar(IRtParent parent)
			: base(parent)
		{
			this.grm_idx = alib.Array.arr.Append(ref arr, this);

			this.dps = new DirectoryPathSet(this);
		}

		public readonly int grm_idx;

		bool IsNameMatch(String name)
		{
			return
				String.Equals(this.Name, name, StringComparison.InvariantCultureIgnoreCase) ||
				String.Equals(this.display_name, name, StringComparison.InvariantCultureIgnoreCase);
		}

		public ItemCulture ItemCulture { get; set; }

		///////////////////////////////////////////////////////////////////////
		/// 
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		DirectoryPathSet dps;
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public DirectoryPathSet DefaultDirectories
		{
			get { return dps; }
			set
			{
				if (value == null || value.Count == 0)
					return;
				if (dps.Count > 0)
					throw not.impl;
				dps = value;
			}
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		public AgreeConfig config;
		public AgreeConfig AgreeConfig
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return this.config; }
			set { this.config = value; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		String display_name;
		public String DisplayName
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return display_name; }
			set { display_name = value; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		String _author;
		public String Author
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return _author; }
			set { _author = value; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		///
		/// 
		public TypeLattice bcpo;
		public TypeLattice TypeLattice
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return this.bcpo; }
			set { throw not.valid; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////

		///////////////////////////////////////////////////////////////////////
		///
		/// 
		public GlbCache glbc;
		public GlbCache GlbCache
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return this.glbc; }
			set { throw not.valid; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		public TypeDictionary td;
		public TypeDictionary TypeDictionary
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return this.td; }
			set { throw not.valid; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		public FeatMgr ftm;
		public FeatMgr FeatMgr
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return this.ftm; }
			set { throw not.valid; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		public Isometrics im;
		public Isometrics Isometrics
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return this.im; }
			set { throw not.valid; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		public TypeUtils tu;
		public TypeUtils TypeUtils
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return this.tu; }
			set { throw not.valid; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		///
		public TfsUnifier fsu;
		public TfsUnifier TfsUnifier
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return this.fsu; }
			set { throw not.valid; }
		}
		///
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		public EntryMgr em;
		public EntryMgr EntryMgr
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return this.em; }
			set { throw not.valid; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		public NodeLabeler nl;
		public NodeLabeler NodeLabeler
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return this.nl; }
			set { throw not.valid; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		///
		public MrsManager mrsm;
		public MrsManager MrsManager
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return this.mrsm; }
			set { throw not.valid; }
		}
		///
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		///
		public QuickCheck qc;
		public QuickCheck QuickCheck
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return this.qc; }
			set { throw not.valid; }
		}
		///
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		///
		public semi.SemI semi;
		public semi.SemI SemI
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return this.semi; }
			set { if ((semi = value) != null && vpm == null) vpm = semi.Vpm; }
		}
		///
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		///
		public semi.Vpm vpm;
		public semi.Vpm Vpm
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return this.vpm; }
			set { this.vpm = value; }
		}
		///
		///////////////////////////////////////////////////////////////////////
	};


	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/// <summary>
	/// 
	/// </summary>
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	[UsableDuringInitialization(true)]
	public abstract class has_grammar_base : identity_named_init,
		ρρGrammar,
		ρρAgreeConfig,
		ρρTypeDictionary,
		ρρTypeUtils,
		ρρGlbCache,
		ρρFeatMgr,
		ρρIsometrics,
		ρρTypeLattice,
		ρρTfsUnifier,
		ρρEntryMgr,
		ρρNodeLabeler,
		ρρMrsManager,
		ρρQuickCheck,
		ρρSemI,
		ρρVpm
	{
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		static Grammar find_grammar(IIdentity item)
		{
			has_grammar_base hg;
			ρρGrammar gp;

			return item as Grammar ??
				((hg = item as has_grammar_base) != null ?
					hg.g :
					((gp = item as ρρGrammar) != null ?
						gp.Grammar :
						default(Grammar)));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public has_grammar_base(IRtParent parent, Grammar _g, String name)
			: base(parent, (_g = find_grammar(_g ?? parent)) ?? parent, name)
		{
			this.Grammar = _g;
		}
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public has_grammar_base(IRtParent parent, Grammar _g)
			: this(parent, _g, default(String))
		{
		}
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public has_grammar_base(IRtParent parent, has_grammar_base hgb, String name)
			: this(parent, hgb.g, name)
		{
		}
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public has_grammar_base(IRtParent parent, String name)
			: this(parent, default(Grammar), name)
		{
		}
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public has_grammar_base(IRtParent parent)
			: this(parent, default(String))
		{
		}

		///////////////////////////////////////////////////////////////////////
		/// 
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		protected Grammar g;
		public Grammar Grammar
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return this.g; }
			set
			{
				if (value == null)
					return;
				else if (this.g == null)
					this.g = value;
				else if (this.g != value)
					throw new Exception(String.Format("grammar property for '{0}' is write-once", this.GetType()._Name()));

				if (this.config == g.config)
					this.config = null;

				if (this is TypeLattice)
					g.bcpo = (TypeLattice)this;
				else if (this is TypeDictionary)
					g.td = (TypeDictionary)this;
				else if (this is FeatMgr)
					g.ftm = (FeatMgr)this;
				else if (this is TfsUnifier)
					g.fsu = (TfsUnifier)this;
				else if (this is EntryMgr)
					g.em = (EntryMgr)this;
				else if (this is TypeUtils)
					g.tu = (TypeUtils)this;
				else if (this is Isometrics)
					g.im = (Isometrics)this;
				else if (this is GlbCache)
					g.glbc = (GlbCache)this;
				else if (this is NodeLabeler)
					g.nl = (NodeLabeler)this;
				else if (this is MrsManager)
					g.mrsm = (MrsManager)this;
				else if (this is QuickCheck)
					g.qc = (QuickCheck)this;
				else if (this is Lexicon)
					g.em.lex = (Lexicon)this;
			}
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		AgreeConfig config;
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public AgreeConfig AgreeConfig
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get
			{
				if (this.config != null)
					return this.config;
				return g != null ? g.config : null;
			}
			set { this.config = value; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public TypeDictionary td
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g == null ? null : g.td; }
		}
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public TypeDictionary TypeDictionary
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g == null ? null : g.td; }
			set { (this.Grammar = value.g).td = value; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public TypeLattice bcpo
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g.bcpo; }
		}
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public TypeLattice TypeLattice
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g.bcpo; }
			set { (this.Grammar = value.g).bcpo = value; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public GlbCache glbc
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g.glbc; }
		}
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public GlbCache GlbCache
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g.glbc; }
			set { (this.Grammar = value.g).glbc = value; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public FeatMgr ftm
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g.ftm; }
		}
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public FeatMgr FeatMgr
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g.ftm; }
			set { (this.Grammar = value.g).ftm = value; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public Isometrics im
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g.im; }
		}
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public Isometrics Isometrics
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g.im; }
			set { (this.Grammar = value.g).im = value; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public TypeUtils tu
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g.tu; }
		}
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public TypeUtils TypeUtils
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g.tu; }
			set { (this.Grammar = value.g).tu = value; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		///
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public TfsUnifier fsu
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g.fsu; }
		}
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public TfsUnifier TfsUnifier
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g.fsu; }
			set { (this.Grammar = value.g).fsu = value; }
		}
		///
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public EntryMgr em
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g == null ? null : g.em; }
		}
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public EntryMgr EntryMgr
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g == null ? null : g.em; }
			set { (this.Grammar = value.g).em = value; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public NodeLabeler nl
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g == null ? null : g.nl; }
		}
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public NodeLabeler NodeLabeler
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g == null ? null : g.nl; }
			set { (this.Grammar = value.g).nl = value; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		///
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public MrsManager mrsm
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g == null ? null : g.mrsm; }
		}
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public MrsManager MrsManager
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g == null ? null : g.mrsm; }
			set { (this.Grammar = value.g).mrsm = value; }
		}
		///
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public QuickCheck QuickCheck
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g == null ? null : g.QuickCheck; }
			set { throw not.valid; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public semi.SemI SemI
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g == null ? null : g.SemI; }
			set { throw not.valid; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////


		///////////////////////////////////////////////////////////////////////
		/// 
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public semi.Vpm Vpm
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return g == null ? null : g.Vpm; }
			set { throw not.valid; }
		}
		/// 
		///////////////////////////////////////////////////////////////////////
	};

	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/// 
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	public abstract class seq_grammar_base : identity_seq_child, ρρGrammar
	{
		protected seq_grammar_base(sync_obj_ctor_arg _) : base(_) { }
		protected seq_grammar_base(IRtParent parent, IIdentity prv, Grammar g)
			: base(parent, prv)
		{
			if (this.g == null)
				this.g = g;
		}
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		Grammar g;
		public Grammar Grammar { [MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough] get { return g; } set { throw not.valid; } }

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public AgreeConfig config { [MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough] get { return g == null ? null : g.config; } }
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public TypeDictionary td { [MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough] get { return g == null ? null : g.td; } }
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public TypeLattice bcpo { [MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough] get { return g == null ? null : g.bcpo; } }
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public GlbCache glbc { [MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough] get { return g == null ? null : g.glbc; } }
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public FeatMgr ftm { [MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough] get { return g == null ? null : g.ftm; } }
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public Isometrics im { [MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough] get { return g == null ? null : g.im; } }
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public TypeUtils tu { [MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough] get { return g == null ? null : g.tu; } }
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public TfsUnifier fsu { [MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough] get { return g == null ? null : g.fsu; } }
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public EntryMgr em { [MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough] get { return g == null ? null : g.em; } }
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public NodeLabeler nl { [MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough] get { return g == null ? null : g.nl; } }
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public MrsManager mrsm { [MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough] get { return g == null ? null : g.mrsm; } }
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public semi.SemI semi { [MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough] get { return g == null ? null : g.semi; } }
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public semi.Vpm vpm { [MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough] get { return g == null ? null : g.vpm; } }

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public TokenMappingGeometry tmg { [MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough] get { return g == null ? null : em.TokenMappingGeometry; } }
	};


	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/// 
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	public abstract class seq_typedict_named : seq_grammar_base, ρρName
	{
		protected seq_typedict_named(sync_obj_ctor_arg _) : base(_) { }
		protected seq_typedict_named(IRtParent parent, IIdentity prv, Grammar g, String name)
			: base(parent, prv, g)
		{
			this.name = name;
		}
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		String name;
		public String Name
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return name; }
			set { name = value; }
		}
	};

	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/// 
	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	public abstract class seq_entrymgr_base : seq_grammar_base
	{
		protected seq_entrymgr_base(IRtParent parent, IIdentity prv, EntryMgr em)
			: base(parent, prv ?? em, em == null ? null : em.Grammar)
		{
		}

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		public EntryMgr EntryMgr
		{
			[MethodImpl(MethodImplOptions.AggressiveInlining), DebuggerStepThrough]
			get { return Grammar == null ? null : Grammar.em; }
		}
	};
}
